<template>
  <div>
    <a-card :body-style="{ padding: '24px 32px' }" :bordered="false">
    <a-form @submit="submit" :form="form">
      <a-form-item
        :label="$t('dataHealthTime')"
        :labelCol="{ span: 7 }"
        :wrapperCol="{ span: 10 }"
      >
        <a-input
          v-decorator="[
            'dataHealthTime',
            { rules: [{ required: true, message: '实时数据缓存时间不得为空' }] },
          ]"
          :placeholder="$t('dataHealthTimeInput')"
        />
      </a-form-item>
      <a-form-item
        :label="$t('versionNo')"
        :labelCol="{ span: 7 }"
        :wrapperCol="{ span: 10 }"
      >
        <a-input
          v-decorator="[
            'versionNo',
            { rules: [{ required: true, message: '系统版本不得为空' }] },
          ]"
          :placeholder="$t('versionNoInput')"
        />
      </a-form-item>
    </a-form>
  </a-card>
  <footer-tool-bar>
      <a-button type="primary" @click="submit" :loading="loading">{{$t('submit')}}</a-button>
    </footer-tool-bar>
  </div>
  
</template>

<script>
import { settingUpdate, settingDetail } from "@/services/setting";
import FooterToolBar from '@/components/tool/FooterToolBar'
export default {
  name: "BasicForm",
  i18n: require("./i18n"),
  components: {FooterToolBar},
  data() {
    return {
      form: this.$form.createForm(this),
      value: 1,
      productList: [],
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      settingDetail(this.$route.params.id).then((rep) => {
        const data = rep.data.data;
        this.form.setFieldsValue({
          dataHealthTime: data.dataHealthTime,
          versionNo: data.versionNo,
        });
      });
    },
    submit() {
      this.form.validateFields((err, values) => {
        if (!err) {
          values.id = this.$route.params.id;
          settingUpdate(values).then((rep) => {
            if (rep.data.success) {
              this.$message.success("更新系统配置成功");
            } else {
              this.$message.error(rep.data.msg);
            }
          });
        }
      });
    },
  },
  computed: {
    desc() {
      return this.$t("pageDesc");
    },
  },
};
</script>

<style scoped>
</style>
